{extend name="layout:base" /}{block name="content"}
 <?php
$global=isSupperManagerForSession();

 ?>
<style>
.calender{width:96%;margin:10px auto;}
.calender table{width:100%;text-align: center; border-collapse: collapse;}
.calender table .calender_h{display:inline-block;width:33.3%;float:left;text-align:center;cursor:pointer}

.calender table thead th{height:30px;line-height:30px;font-weight:800;font-size:14px;text-align:center;border:1px solid #cfcfcf;}
.calender table tbody td{height:90px;line-height:26px;font-weight:800;font-size:14px;text-align:center;border:1px solid #cfcfcf;}
.calender table .td_relation{position: relative;cursor:pointer;}
.calender table .date_number{position: absolute; top:2px;right:5px;color:#ccc;font-size:14px;}
.calender table .date_memo{color:#666;font-size:16px;width:100%; }
.jingliTitle{height:30px;line-height:30px;font-size:18px;text-align:center;color:red;}



.taskItem{height:30px;line-height:30px;width:90%;margin-left:auto;margin-right:auto;font-size:14px;overflow:hidden;text-align:left;}
.taskItem .img{width:22px;}
</style>
<script type="text/javascript" src="/static/js/echarts.js"></script>
<link rel="stylesheet" type="text/css" href="/static/My97DatePicker/skin/WdatePicker.css" />
     <script charset="utf-8" src="/static/My97DatePicker/WdatePicker.js"></script>
     
     <section class="topBanners">
         <div class="icon"></div>
         <div class="topBannersNav">
          <span data-url="/admin/my/fjMyApply" onclick="ContentLoadGo('/admin/my/fjMyApply')">警力申请</span>
         
         </div>
      </section>
       
      
     

    <input type="hidden" name="input_month" id="input_month" />
    <div class="jingliTitle">操作提示：点击具体日期对应的单元格，申请该日警力</div>
    <div class="calender">
        <table>
            <thead>
	            <tr>
	            <th colspan="7">
	               
		            <span class="calender_h" id="lastMonth" data="<?php echo $lastMonth; ?>">上一月</span>
		            <span class="calender_h" id="currMonth" data="<?php echo $currDate ?>"><?php echo $list['year'].'年 '.$list['month']; ?></span>
		            <span class="calender_h" id="nextMonth" data="<?php echo $nextMonth ?>">下一月</span>
	            </th>
	            </tr>
	            <tr><th>日</th><th>一</th><th>二</th><th>三</th><th>四</th><th>五</th><th>六</th>
	        </thead>
            <tbody>
            <tr>
                <?php
                $string = '';
                foreach($list['cal'] as $k => $v) 
				{
                       if($k && !($k % 7))
					    {
                        	$string .= '</tr><tr>';
                        }
						$tabDate=$list['year'];
						if($list['month_num']<10)
						{
							$tabDate.='-0'.$list['month_num'];
						}
						else
						{
							$tabDate.='-'.$list['month_num'];
						}
						if($v<10)
						{
							$tabDate.='-0'.$v;
						}
						else
						{
							$tabDate.='-'.$v;
						}
						$style='';
						$style1='';
						$myKey=$k%7;
                        if($tabDate==$currDate)
						{
								
								$style='background-color:#3d7ba8;padding:2px 4px;top:0px;right:0px;color:white;';
						}
  						if($tabDate>=$currDate && $myKey>0 && $myKey<6)
						{
								
								$style='background-color:#3d7ba8;padding:2px 4px;top:0px;right:0px;color:white;';
						}

						if($tabDate==$currDate)
						{
								//$style1='background-color:#b87333';
						}


                    $string .='<td class="td_relation" style="'.$style1.'">';
  					if($v)
					{
                        $tmp_free = $totlePoliceNum-$policeMonthCount[$v-1];
						$string .='<div class="date_number" style="'.$style.'" free="'.$tmp_free.'" data="'.$tabDate.'">';
						if($tabDate==$currDate)
						{
							$string .='今日';
						}
						else
						{
							$string .=$v;
						}
						$string .='</div>';
						if( $tabDate>=$currDate)
						{
						 $string .='<div class="date_memo" >';

						
                         $string .="<div class='taskItem'><img style='width:18px;margin-right:4px;' src='/static/images/icon/JC_bzsy.png' />已排<font style='color:red;'> ".$policeMonthCount[$v-1]." </font>人</div>";
						 $string .="<div class='taskItem'><img style='width:18px;margin-right:4px;' src='/static/images/icon/JC_free.png' />空闲<font style='color:green;'> ".$tmp_free." </font>人</div>";
						 $string .='</div>';
						}
					}
					$string .='</td>';
                }
				echo $string;
                ?>
            </tr>
            </tbody>
        </table>
    </div>





 <script type="text/javascript">
      
      function myResearch(){
		   var url="/admin/my/fjMyApply";
		  
		   var month =$("#input_month").val();
		  
		   var param={
				   month:month
		   };
		   ContentLoadGo(url,param);
	   }
     
      
           $(function(){
        	   //设置搜索栏
        	   $(".research").click(function(){
        		   var page =$(this).attr("page");
        		   $("#cpage").val(page);
        		   myResearch();
        		   
        	   });
        	   $("#lastMonth").unbind().bind("click",function(){
        		   $("#input_month").val($(this).attr("data"));
        		   myResearch();
        	   });
 				$("#nextMonth").unbind().bind("click",function(){
 					$("#input_month").val($(this).attr("data"));
 					myResearch(); 
        	   });
 				
 				$(".td_relation").unbind().bind("click",function(){
 					var that =this;
 					var currDate='<?php echo $currDate; ?>';
 					var opTime = $(this).children(".date_number").attr("data");
 					var freenum = $(this).children(".date_number").attr("free");
 					if(opTime!=undefined && opTime!="" && opTime!='undefined' )
 					{
 						   if(opTime>=currDate)
 						   {
 							   if(freenum>0)
 							   {
		 		        		   var url="/admin/my/addFjDataJob";
		 		        		   var param={
		 		        				  opTime:opTime
		 		        		   };
		 		        		   MyContentLoad(url,param);
 							   }else
 							   {
 								  cofirmsss_tishi(1,'系统检测到该日无空闲警力，你确定要继续申请吗？',function(tmpId){
 									   var url="/admin/my/addFjDataJob";
 			 		        		   var param={
 			 		        				  opTime:opTime
 			 		        		   };
 			 		        		   MyContentLoad(url,param);
 								  });
 							   }
 						   }else
 						   {
 							  ErrTiShi("对不起，该日期已经不能够再申请警力了");return false;
 						   }
 		        				 
 					}
        	   });
        	  
 				
        	   //导航
         	   $(".topBannerItem").click(function(){
         		   
         		   var attArr = $(this).attr();
             	   goToSelfLink(attArr);
             	   
         			
         	   });
        	
        	   
         	  $(".daochu").click(function(){
       		   var url='/admin/job/daochuJc';
       		   var starttime =$("#starttime").val();
       		   var endtime =$("#endtime").val();
       		  
       		   var param={
       				   starttime:starttime, 
       				   endtime:endtime, 
       				   page:1
       		   };
       		   
       		   
       		   
       		   url=url+"?starttime="+starttime+"&endtime="+endtime+"&page=1";
       		   		
       		   	  
       		   	
       		   	window.location.href=url;
       		   
       	   });
        	   
        	 
        	   
  			   //全选
  		
  				$("#all").click(function(){   
			    	if(this.checked){   
			        	$(".checkBoxInput").attr("checked", true);  
			        	$(".checkBoxInput").prop("checked", true);  
			    	}else{   
						$(".checkBoxInput").attr("checked", false);
						$(".checkBoxInput").prop("checked", false);
			    	}   
			    	var se=getAllSelectItem();
			    	//console.log(se);
			 	}); 
  			   
  			   
  				
           });
           
	  </script>
   {/block}
